<template>
  <div>
    <!-- 头部区域 -->
    <top :f1="true" :f2="false"></top>
    <!-- 主体部分 -->
    <div class="detail">
      <h3 class="title">{{ info.title }}</h3>
      <div class="info">
        <span>发表时间: {{ info.add_time | dateFormat }}</span>
        <span>点击次数: {{ info.click }}</span>
      </div>
      <div v-html="info.content" class="content"></div>
    </div>
    <my-comment :id="id"></my-comment>
    <!-- 底部导航 -->
    <bottom></bottom>
  </div>
</template>

<script>
import Comment from '../Comment.vue'
export default {
  data() {
    return {
      id: 0,
      info: {}
    }
  },
  components: {
    'my-comment': Comment
  },
  created() {
    this.id = this.$route.params.id
    this.getDetail()
  },
  methods: {
    async getDetail() {
      const { data: res } = await this.axios.get(`/api/getnew/${this.id}`)
      console.log(res)
      if (res.status !== 0) {
        return this.$toast('获取新闻详情失败')
      }
      this.info = res.message[0]
      console.log(this.info)
    }
  }
}
</script>

<style lang="less" scoped>
.detail {
  padding: 0 10px;
  .title {
    position: relative;
    top: 40px;
    color: #1989fa;
    font-size: 14px;
    text-align: center;
    line-height: 30px;
    margin: 0;
    padding: 5px 0;
  }
  .info {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #1989fa;
    border-bottom: 1px solid #ccc;
    padding: 7px 0px;
    position: relative;
    top: 40px;
  }
  .content {
    padding-top: 40px;
  }
}
</style>
